package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	OwnerEventNew           = "pm.OwnerNew"
	OwnerEventBeforeCreate  = "pm.OwnerBeforeCreate"
	OwnerEventBeforeUpdate  = "pm.OwnerBeforeUpdate"
	OwnerEventBeforeSave    = "pm.OwnerBeforeCreate pm.OwnerBeforeUpdate"
	OwnerEventAfterCreate   = "pm.OwnerAfterCreate"
	OwnerEventAfterUpdate   = "pm.OwnerAfterUpdate"
	OwnerEventAfterSave     = "pm.OwnerAfterCreate pm.OwnerAfterUpdate"
	OwnerEventDelete        = "pm.OwnerDelete"
	OwnerAccessControlEvent = "pm.OwnerAccessControl"
)

func GetOwnerConfig() *mgo.DocConfig {
	return Owner_Config
}

var Owner_Config *mgo.DocConfig

func init() {
	Owner_Config = NewOwnerConfig()
}
func NewOwnerConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "pm.Owner",
		Fields: []string{
			"house", "name", "idCard", "mobile", "address", "note",
		},
		RelationFields: []string{
			"house",
		},
		RelationConfigs: map[string]*mgo.DocRelation{
			"house": {
				Config:     GetHouseConfig,
				DocName:    "House",
				JoinType:   "MM",
				KeyInside:  "houseId",
				KeyOutSide: "id",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
